import cv2 as cv
#filename ='/home/zy/pycharm/opencv-4.2.0/samples/data/lena.jpg'
#img=cv.imread(filename)
#imgGauss = cv.GaussianBlur(img,(5,5),0)
#image1=cv.resize(img,(int(img.shape[1]/2),int(img.shape[0]/2)))
#image2=cv.pyrDown(image1)
#gray =cv.cvtColor(img,cv.COLOR_BGR2GRAY)
#_,gray1=cv.threshold(gray,120,255,cv.THRESH_BINARY)

#cv.imshow("source.image",img)
#cv.imshow("Gaussian filthered image",imgGauss)
#cv.imshow("half size",image1)
#cv.imshow("quarter size",image2)
#cv.imshow("gray",gray)
#cv.imshow("threshold image",gray1)
#cv.waitKey()
#cv.destroyAllWindows()



import cv2
import numpy as np
import matplotlib.pylab  as plt

img = cv2.imread("/home/zy/pycharm/opencv-4.2.0/samples/data/lena.jpg")
gray2 =cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh1 = cv.threshold(gray2,127,255,cv2.THRESH_BINARY)
ret,thresh2 = cv.threshold(gray2,127,255,cv2.THRESH_BINARY_INV)
ret,thresh3 = cv.threshold(gray2,127,255,cv2.THRESH_TRUNC)
ret,thresh4 = cv.threshold(gray2,127,255,cv2.THRESH_TOZERO)
ret,thresh5 = cv.threshold(gray2,127,255,cv2.THRESH_TOZERO_INV)

titles = ['Original Image','BINARY','BINARY_INV','TRUNC','TOZERO','TOZERO_INV']
images = [img, thresh1, thresh2, thresh3, thresh4, thresh5]

#oricode#for i in range(6):
    #plt.subplot(2,3,i+1),plt.imshow(images[i],'gray')
    #plt.title(titles[i])
    #plt.xticks([]),plt.yticks([])
#plt.show()
for i in range(6):

 cv.imshow(titles[i],images[i])
 cv.imshow(titles[i],images[i])
 cv.imshow(titles[i],images[i])
 cv.imshow(titles[i],images[i])
 cv.imshow(titles[i],images[i])
cv.waitKey()
cv.destroyAllWindows()
